var app = getApp();
var ux = require('../../../lib/ux.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId: null,
    banrd: {},
    order: {},
    list: [],
    action: "/api/balance/getOrderInfos.do",
    submit: "{{submit}}"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var self = this;
    ux.login(function (protocol) {
      if (protocol.success) {
        wx.setStorageSync("userInfo", protocol.data.userInfo);
        wx.setStorageSync("token", protocol.data.token);
        self.setData({
          userInfo: protocol.data.userInfo
        })
      }
    });
    if (options.orderId) {
      this.setData({
        orderId: options.orderId
      })
    }
    var params = { orderId: 1 }
    ux.request(this.data.action, options, function (protocol) {
      app.globalData.thisBrand = data.data.banrd.id;
      self.setData({
        banrd: data.data.banrd,
        order: data.data.order,
        list: data.data.list,
      })
    }, true);
  },

  onForm: function (event) {
    if (this.data.submit) {
      var $this = this;
      var dataset = event.currentTarget.dataset;
      ux.request(this.data.submit, detail.value, function (protocol) {
        if (protocol.success) {
          if (dataset.url) {
            wx.redirectTo(dataset.url);
          }
        }
      }, true);
    }
  },

  onTap: function (event) {
    var dataset = event.currentTarget.dataset;
    var data = this.data;
    if (dataset.key && dataset.val) {
      data[dataset.key] = dataset.val;
    }
    this.setData(data);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  
  look: function () {
    wx.navigateTo({
      url: '/pages/protocol/explain',
    })
  }
})
